package com.lm.kilim.example;

import kilim.Mailbox;
import kilim.Pausable;
import kilim.Task;

public class MailboxExample {
    public static void main(String[] args) {
        Mailbox<String> mailbox = new Mailbox<>();

        // 生产者 Task
        new Task() {
            @Override
            public void execute() throws Pausable {
                mailbox.putnb("Hello from Producer");
            }
        }.start();

        // 消费者 Task
        new Task() {
            @Override
            public void execute() throws Pausable {
                String msg = mailbox.get(); // get() 是阻塞点，可以抛 Pausable
                System.out.println("Consumer received: " + msg);
            }
        }.start();
    }
}
